/* ***********************************************************************
 * 项目名称:油耗
 * 项目组:
 * 创建时间:2017.7.11
 * 创建人:马方印
 * 用途:
 * 版本:1.0
 * 修改记录:    修改内容   修改原因   修改人   修改时间
 *               无        无       无       无
 *************************************************************************/

#import "YZRecordTitleView.h"

@implementation YZRecordTitleView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self addSubview:self.topSeparatorView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.litreLabel];
        [self addSubview:self.timeLable];
        [self addSubview:self.bottomSeparatorView];
        
        [self setSubViewsFrame];
    }
    
    return self;
}

#pragma mark - 设置显示标题
- (void)setType:(NSInteger)type{
    _type = type;
    
    if (type == 0) {//入油
        
        self.nameLabel.text = @"发油单位";
        self.litreLabel.text = @"入油量";
        self.timeLable.text = @"入油时间";
    }
    else if (type == 1){//出油
        
        self.nameLabel.text = @"出油车辆";
        self.litreLabel.text = @"出油量";
        self.timeLable.text = @"出油时间";
    }
    else if (type == 2){//加油
        
        self.nameLabel.text = @"加油车辆";
        self.litreLabel.text = @"加油量";
        self.timeLable.text = @"加油时间";
    }
}

#pragma mark - 布局
- (void)setSubViewsFrame{
    
    [self.topSeparatorView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.mas_top);
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(@1);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.mas_left);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.litreLabel.mas_left);
        make.width.mas_equalTo(self.litreLabel);
    }];
    
    [self.litreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.nameLabel.mas_right);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.timeLable.mas_left);
        make.width.mas_equalTo(self.timeLable);
    }];
    
    [self.timeLable mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.litreLabel.mas_right);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.right.mas_equalTo(self.mas_right);
    }];
    
    [self.bottomSeparatorView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.mas_bottom);
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
        make.height.mas_equalTo(@1);
    }];
}

#pragma mark - 懒加载
- (UILabel *)timeLable{
    
    if (!_timeLable) {
        
        _timeLable = [[UILabel alloc]init];
        _timeLable.text = @"出油时间";
        _timeLable.font = [UIFont systemFontOfSize:18.0f];
        _timeLable.textColor = COLOR(0, 153, 204, 1);
        _timeLable.frame = CGRectMake(0, 64, kScreenWidth, 44);
        _timeLable.textAlignment = NSTextAlignmentCenter;
    }
    
    return _timeLable;
}

- (UILabel *)litreLabel{

    if (!_litreLabel) {

    _litreLabel = [[UILabel alloc]init];
    _litreLabel.text = @"出油量";
    _litreLabel.font = [UIFont systemFontOfSize:18.0f];
    _litreLabel.textColor = COLOR(0, 153, 204, 1);
    _litreLabel.frame = CGRectMake(0, 64, kScreenWidth, 44);
    _litreLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return _litreLabel;
}

- (UILabel *)nameLabel{
    
    if (!_nameLabel) {
        
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"加油车辆";
        _nameLabel.font = [UIFont systemFontOfSize:18.0f];
        _nameLabel.textColor = COLOR(0, 153, 204, 1);
        _nameLabel.frame = CGRectMake(0, 64, kScreenWidth, 44);
        _nameLabel.textAlignment = NSTextAlignmentCenter;
    }
    
    return _nameLabel;
}

- (UIView *)bottomSeparatorView{
    
    if (!_bottomSeparatorView) {
        
        _bottomSeparatorView = [[UIView alloc]init];
        _bottomSeparatorView.backgroundColor = COLOR(0, 153, 204, 1);
    }
    
    return _bottomSeparatorView;
}

- (UIView *)topSeparatorView{
    
    if (!_topSeparatorView) {
        
        _topSeparatorView = [[UIView alloc]init];
        _topSeparatorView.backgroundColor = COLOR(0, 153, 204, 1);
    }
    
    return _topSeparatorView;
}

@end
